package com.bym.rocket;

import com.alibaba.fastjson.JSON;
import com.bym.vo.BymMessage;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * <h1>第一个 RocketMq 消费者</h1>
 */
@Slf4j
@Component
@RocketMQMessageListener(
        topic = "imooc-study-rocketmq",
        consumerGroup = "bym-springboot-rocketmq-string"
)
public class RocketMQConsumerString implements RocketMQListener<String> {

    @Override
    public void onMessage(String message) {
        BymMessage rocketMessage = JSON.parseObject(message, BymMessage.class);
        log.info("consume message in RocketMQConsumerString: [{}]", JSON.toJSONString(rocketMessage));
    }
}
